package cn.wolfcode.p2p.base.service.impl;

import cn.wolfcode.p2p.base.mapper.SystemDictionaryItemMapper;
import cn.wolfcode.p2p.base.service.ISystemDictionaryItemService;

import cn.wolfcode.p2p.base.domain.SystemDictionaryItem;

import java.util.List;

import cn.wolfcode.base.QueryObject;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class SystemDictionaryItemServiceImpl implements ISystemDictionaryItemService {
    @Autowired
    private SystemDictionaryItemMapper systemDictionaryItemMapper;

    @Override
    @Transactional(readOnly = true)
    public PageInfo<SystemDictionaryItem> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<SystemDictionaryItem> list = systemDictionaryItemMapper.selectList(qo);
        return new PageInfo<SystemDictionaryItem>(list);
    }

    @Override
    public void saveOrUpdate(SystemDictionaryItem entity) {
        if (entity.getId() != null){
            systemDictionaryItemMapper.updateById(entity);
        } else {
            systemDictionaryItemMapper.insert(entity);
        }
    }

    @Override
    public List<?> listItemBySn(String sn) {
        return systemDictionaryItemMapper.selectBySn(sn);
    }
}
